package com.github.ghsea.dbtracer.sample;

import java.util.Date;

import com.github.ghsea.dbtracer.Bootstrap;
import com.github.ghsea.dbtracer.interceptor.DbTracerContext;
import com.github.ghsea.dbtracer.sample.module.TestModule;
import com.github.ghsea.dbtracer.sample.repository.TestModuleDao;
import com.github.ghsea.dbtracer.sample.service.SpringUtil;

public class App {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		Bootstrap.setUp("dbtrace.properties");
		// 到dao操作的这个过程不能切换线程，否则值无法传递
		DbTracerContext.setOperator("ghsea");

		TestModuleDao dao = SpringUtil.getBean(TestModuleDao.class);
		TestModule module = new TestModule();
		module.setId(1L);
		module.setAddress("wuhan23");
		module.setCreateTime(new Date());

		dao.updateByPk(module);
		
		//If service failed,we could do like this to rollback dbtracer log.
		DbTracerContext.fail();
		DbTracerContext.clean();
	}

}
